package com.justplay.mobilelocation.UI;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.justplay.mobilelocation.R;
import com.justplay.mobilelocation.util.InputActivityUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;


public class ParameterSettingActivity extends AppCompatActivity {

    @Bind(R.id.container)
    LinearLayout container;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_parameter_setting);
        ButterKnife.bind(this);
        initView(container);
    }

    private void initView(ViewGroup viewGroup) {
        for (int i = 0; i < viewGroup.getChildCount(); i++) {
            View v=viewGroup.getChildAt(i);
            if (v instanceof LinearLayout) {
                initView((ViewGroup)v);
            }else{
                if ( v instanceof CheckBox){
                    CheckBox checkBox = (CheckBox)v;

                    checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                            InputActivityUtil.gotoInputCodeActivity(ParameterSettingActivity.this);

                        }
                    });
                }
            }


        }
    }

    @OnClick(R.id.container)
    public void onClick() {
        Toast.makeText(this, "...", Toast.LENGTH_SHORT).show();
    }
}
